﻿using Hidistro.Core;
using Hidistro.SaleSystem.Catalog;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class sf_vshop_sixproduct : WebControl
    {
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder builder = new StringBuilder();
            List<int> l = new List<int>();
            l.Add(this.cid);
            DataTable dt = ProductBrowser.GetVistiedProducts(l);
            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                builder.AppendFormat("<a href=\"{0}\">", Globals.ApplicationPath + "/Vshop/ProductDetails.aspx?ProductId=" + row["ProductId"]);
                builder.AppendFormat("<img src=\"{0}\"/>", Globals.GetImgUrl(row["ThumbnailUrl100"].ToString()));
                builder.Append("<div class=\"info\">");
                builder.AppendFormat("<div class=\"name bcolor\">{0}</div>", row["ProductName"]);
                builder.AppendFormat("<div class=\"price font-s text-danger\">￥{0}</div>", Globals.FormatMoney((decimal)row["MarketPrice"]));
                builder.Append("</div></a>");
            }
            writer.Write(builder.ToString());
        }
        public int cid { get; set; }
    }
}
